﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace LuanVanProject
{
    /// <summary>
    /// Interaction logic for AddNewMindmap.xaml
    /// </summary>
    public partial class AddNewMindmap : Window
    {
        public bool result;
        public static string name;
        public AddNewMindmap()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (textBox1.Text != "")
            {
                name = textBox1.Text;
                string path = App.ProjectDirectory + "/Mindmaps/" + AddNewMindmap.name + ".xml";
                if (System.IO.File.Exists(path))
                {
                    MessageBox.Show("Please select different name. This name has been used");
                    return;
                }
                result = true;
                this.Close();
            }
            else
            {
                MessageBox.Show("Please Enter Mindmap Name");
            }
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            result = false;
            this.Close();
        }

        private void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            System.Windows.Input.FocusManager.SetFocusedElement(this,this.textBox1);
        }
    }
}
